package com.sxjh.controller.scalereport;

import com.sxjh.common.BaseController;
import com.sxjh.common.Result;
import com.sxjh.common.ZPage;
import com.sxjh.config.ExcelCacheConfig;
import com.sxjh.entity.ExcelEntity;
import com.sxjh.entity.param.ScaleReportParam;
import com.sxjh.entity.result.ScaleReportResult;
import com.sxjh.service.scalereport.ScaleReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/scaler/report/fy")
@Api(tags = "磅单报表（分页）")
public class ScaleReportPageController extends BaseController {

  @Autowired
  private ScaleReportService scaleReportService;

  @ApiOperation("焦炭销售磅单")
  @PostMapping("/jt/xs/bd")
//  @Authorization("cb.finance.list")
  Result<ZPage<ScaleReportResult>> jtXsBd(@RequestBody @Validated ScaleReportParam param) {
    param.setCategoryId(3);
    return ok(scaleReportService.getScaleReportByPage(param));
  }

  @ApiOperation("甲醇销售磅单")
  @PostMapping("/jc/xs/bd")
//  @Authorization("cb.finance.list")
  Result<ZPage<ScaleReportResult>> jcXsBd(@RequestBody @Validated ScaleReportParam param) {
    param.setCategoryId(4);
    return ok(scaleReportService.getScaleReportByPage(param));
  }
  @ApiOperation("焦油加工厂销售磅单")
  @PostMapping("/jyjgc/xs/bd")
//  @Authorization("cb.finance.list")
  Result<ZPage<ScaleReportResult>> jyjgcXsBd(@RequestBody @Validated ScaleReportParam param) {
    param.setCategoryId(5);
    return ok(scaleReportService.getScaleReportByPage(param));
  }
  @ApiOperation("苯精制销售磅单")
  @PostMapping("/bjz/xs/bd")
//  @Authorization("cb.finance.list")
  Result<ZPage<ScaleReportResult>> bjzXsBd(@RequestBody @Validated ScaleReportParam param) {
    param.setCategoryId(6);
    return ok(scaleReportService.getScaleReportByPage(param));
  }
  @ApiOperation("化产品回收厂销售磅单")
  @PostMapping("/hcphsc/xs/bd")
//  @Authorization("cb.finance.list")
  Result<ZPage<ScaleReportResult>> hcphscXsBd(@RequestBody @Validated ScaleReportParam param) {
    param.setCategoryId(7);
    return ok(scaleReportService.getScaleReportByPage(param));
  }
  @ApiOperation("炭黑销售磅单")
  @PostMapping("/th/xs/bd")
//  @Authorization("cb.finance.list")
  Result<ZPage<ScaleReportResult>> thXsBd(@RequestBody @Validated ScaleReportParam param) {
    param.setCategoryId(8);
    return ok(scaleReportService.getScaleReportByPage(param));
  }
  @ApiOperation("煤炭采购磅单")
  @PostMapping("/mt/cg/bd")
  Result<ZPage<ScaleReportResult>> mtCgBd(@RequestBody @Validated ScaleReportParam param) {
    param.setCategoryId(9);
    return ok(scaleReportService.getScaleReportByPage(param));
  }
  @ApiOperation("化工原料采购磅单")
  @PostMapping("/hgyl/cg/bd")
//  @Authorization("cb.finance.list")
  Result<ZPage<ScaleReportResult>> hgylCgBd(@RequestBody @Validated ScaleReportParam param) {
    param.setCategoryId(10);
    return ok(scaleReportService.getScaleReportByPage(param));
  }
  @ApiOperation("化工辅料采购磅单")
  @PostMapping("/hgfl/cg/bd")
//  @Authorization("cb.finance.list")
  Result<ZPage<ScaleReportResult>> hgflCgBd(@RequestBody @Validated ScaleReportParam param) {
    param.setCategoryId(11);
    return ok(scaleReportService.getScaleReportByPage(param));
  }

  @ApiOperation("磅单分页报表导出")
  @PostMapping("/exportReportData")
  Result<String> exportReportData (@RequestBody @Validated ScaleReportParam param) {
    String id = ExcelCacheConfig.setParam(param, ExcelEntity.Type.BD_FY);
    return ok(id);
  }

}
